<!DOCTYPE HTML>
<html style="min-width:inherit;">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="/static/public/jquery-1.11.1.min.js" type="text/javascript"></script>
<link href="/static/public/layer/src/css/layui.css" rel="stylesheet">
<script src="/static/public/layer/src/layui.js"></script>


</head>

<body>


<form class="layui-form"  class="edit_info">
  <div class="layui-form-item" style="padding-top:15px">
    <label class="layui-form-label">姓名</label>
    <div class="layui-input-inline">
      <input value="<{if isset($student)}><{$student['name']}><{/if}>" type="text" name="name" id="name" lay-verify="name" lay-verify="required" autocomplete="off" placeholder="请输入姓名" class="layui-input">
    </div>

    <label class="layui-form-label">手机</label>
    <div class="layui-input-inline">
      <input value="<{if isset($student)}><{$student['phone']}><{/if}>" type="number" name="phone" id="phone" oninput="if(value.length>11)value=value.slice(0,11)" lay-verify="phone" lay-verify="required" placeholder="手机号用于登录网校" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <div class="layui-inline">
      <label class="layui-form-label">生日</label>
      <div class="layui-input-inline">
        <input value="<{if isset($student)}><{$student['birthday']}><{/if}>" type="text" name="birthday" id="birthday" lay-verify="date" placeholder="yyyy-mm-dd" autocomplete="off" class="layui-input" onclick="layui.laydate({elem: this})">
      </div>
    </div>

    <label class="layui-form-label">性别</label>
    <div class="layui-input-inline">
      <{if isset($student)}>
      <input type="radio" name="sex" value="1" title="男" <{if $student['sex']==1 }>checked=""<{/if}> >
      <input type="radio" name="sex" value="2" title="女" <{if $student['sex']==2 }>checked=""<{/if}> >
      <{else}>
      <input type="radio" name="sex" value="1" title="男" checked="">
      <input type="radio" name="sex" value="2" title="女">
      <{/if}>


    </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">微信</label>
    <div class="layui-input-inline">
      <input value="<{if isset($student)}><{$student['wx']}><{/if}>" placeholder="请填写微信" type="text" name="wx" id="wx"   autocomplete="off" class="layui-input">
    </div>

    <div class="layui-inline">
      <label class="layui-form-label">QQ</label>
      <div class="layui-input-inline">
        <input value="<{if isset($student)}><{$student['qq']}><{/if}>" type="text" placeholder="请填写QQ号" name="qq" id="qq" autocomplete="off" class="layui-input">
      </div>
    </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">学历</label>
    <div class="layui-input-inline">
      <select name="edu" id="edu" lay-filter="aihao" lay-verify="required">
        <option value=""></option>
        <{if isset($student)}>
        <option value="1" <{if $student['edu']==1 }>selected<{/if}> >高中</option>
        <option value="2" <{if $student['edu']==2 }>selected<{/if}> >大专</option>
        <option value="3" <{if $student['edu']==3 }>selected<{/if}> >本科</option>
        <option value="4" <{if $student['edu']==4 }>selected<{/if}> >研究生</option>
        <option value="9" <{if $student['edu']==9 }>selected<{/if}> >其他</option>
        <{else}>
        <option value="1" >高中</option>
        <option value="2" >大专</option>
        <option value="3">本科</option>
        <option value="4">研究生</option>
        <option value="9">其他</option>
        <{/if}>

      </select>
    </div>

    <label class="layui-form-label">是否在职</label>
    <div class="layui-input-inline">
      <select name="on_job" id="on_job" lay-filter="aihao" lay-verify="required">
        <option value=""></option>
        <{if isset($student)}>
        <option value="0" <{if $student['on_job']==0 }>selected<{/if}>>非在职</option>
        <option value="1" <{if $student['on_job']==1 }>selected<{/if}>>在职</option>
        <{else}>
        <option value="0">非在职</option>
        <option value="1" >在职</option>
        <{/if}>
      </select>
    </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">上课时间</label>
    <div class="layui-input-block">

      <input type="checkbox" name="class_time" value="0" title="不限">
      <input type="checkbox" name="class_time" value="1" title="白天">
      <input type="checkbox" name="class_time" value="2" title="晚上">
      <input type="checkbox" name="class_time" value="3" title="周末">
      <input type="checkbox" name="class_time" value="4" title="工作日">

    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">住址</label>
    <div class="layui-input-block">
      <input lay-verify="required" value="<{if isset($student)}><{$student['address']}><{/if}>" type="text" placeholder="请输入详细住址，省、市、区、街道 " name="address" id="address" pl autocomplete="off" class="layui-input">
    </div>
  </div>

  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">备注信息</label>
    <div class="layui-input-block">
      <textarea name="remark" id="remark" style="width:460px;" placeholder="请输入备注内容" class="layui-textarea"><{if isset($student)}><{$student['remark']}><{/if}></textarea>
    </div>
  </div>

  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit="" lay-filter="demo1">保存</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>

    </div>
  </div>
</form>


<{include file="footer.html"}>
<script>
layui.use(['form', 'layedit', 'laydate'], function(){
  var form = layui.form()
  ,layer = layui.layer
  ,laydate = layui.laydate;

  //自定义验证规则
  form.verify({
    name: function(value){
      if(value.length < 2){
        return '姓名至少得2个字符啊';
      }
    }
    ,phone: function(value){
      if(!(/^1[34578]\d{9}$/.test(value))){
        return "手机号码有误，请重填";
      }
    }

  });

    var birthday = {
      min: laydate.now(-20000)
      ,max: laydate.now()
      ,istoday: false
      ,choose: function(datas){
        birthday.min = datas; //开始日选好后，重置结束日的最小日期
        birthday.start = datas //将结束日的初始值设定为开始日
      }
    };


    document.getElementById('birthday').onclick = function(){
      birthday.elem = this;
      laydate(birthday);
    }


  //监听提交
  form.on('submit(demo1)', function(data){
    // layer.alert(JSON.stringify(data.field), {
    //   title: '最终的提交信息'
    // })
    // parent.$('#order_submit').text('我被改变了');
    // parent.layer.tips('Look here', '#order_submit', {time: 5000});
    // parent.layer.close(index);
    var name = $("#name").val();
    var phone = $("#phone").val();
    var birthday = $("#birthday").val();
    var sex = $('input[name="sex"]:checked ').val();
    var wx = $("#wx").val();
    var qq = $("#qq").val();
    var edu = $("#edu").val();
    var on_job = $("#on_job").val();
    var class_time =[];
    $('input[name="class_time"]:checked').each(function(){
    class_time.push($(this).val());
    });
    if(class_time.length==0){
      class_time = "";
    }

    var address = $("#address").val();
    var remark = $("#remark").val();

    $.post('/classes/add_offline_student/<{$class_id}>',{'name':name,'phone':phone,'birthday':birthday,'sex':sex,'wx':wx,'qq':qq,'edu':edu,'on_job':on_job,'class_time':class_time,'address':address,'remark':remark},function(res){
        var obj = eval('(' + res + ')');
        if(obj.result==0){
          window.parent.save_close();
        }else {
          alert(obj.msg);
        }
    });

    return false;
  });


});
</script>



</body>
</html>
